<template>
	<view class="box">
		<view class="search">
			<view class="search-button">
				<img class="search-button-img" src="../../static/store/Frame.png" alt="" srcset="" />
				<view class="text">
					地点
				</view>
			</view>
			<view class="line">
			</view>
			<view class="uni-input">
				<uni-search-bar bgColor="#F6F6F6" radius="5" placeholder="请输入搜索内容" clearButton="auto" cancelButton="none"
					inputBorder="false" />
			</view>
		</view>
		<view class="chose-box">
			<view class="chose-all">
				<view @click="Event_clickChouseButton('全部')">
					<image class="chose-image" src="../../static/store/fenlei.png"></image>
					<text class="text-all" :class="{textAllactive:buttonChouseId==='全部'}">全部</text>
				</view>
				<view class="chose-line" v-show="buttonChouseId==='全部'"></view>
			</view>
			<view class="choses-button-box">
				<view class="choses-button" v-for="item in choseData" @click="Event_clickChouseButton(item.text)">
					<image class="choses-button-image" :src="item.imge"></image>
					<text class="choses-button-text" :class="{trueButtonText:buttonChouseId===item.text}">{{ item.text }}</text>
					<view class="chose-line" v-show="buttonChouseId===item.text"></view>
				</view>
			</view>
		</view>
		<scroll-view class="content" scroll-y="true">
			<view @click="routerTo(item)" v-for="item in data.list" class="card">
				<view class="card-left">
					<image class="left-image" :src="item.store_avatar"></image>
				</view>
				<view class="card-mid">
					<view class="card-mid-text">{{item.store_name}}</view>
					<view class="mid-mid">
						<view class="mid-mid-status">
							<view class="text">{{item.classification}}</view>
						</view>
					</view>
					<view class="mid-bottom">
						<image class="image" src="../../static/store/Group 1675.png"></image>
						<view class="text">
							{{item.province}}{{item.city}}{{item.district}}{{item.address}}
						</view>
					</view>
				</view>
				<view class="card-right">
					<view class="text">
						{{item.distance.toFixed(1)}}km
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>
<script setup>
	import {
		ref,
		onMounted,
		getCurrentInstance,
		reactive
	} from 'vue';
	import {
		onLoad,
		onShow
	} from '@dcloudio/uni-app'
	let {
		proxy
	} = getCurrentInstance()
	//分类按钮数据数组
	const choseData = ref([{
			imge: '../../static/store/chose1.png',
			text: '中式黑八'
		},
		{
			imge: '../../static/store/chose1.png',
			text: '斯诺克'
		},
		{
			imge: '../../static/store/chose2.png',
			text: '麻将'
		}
	])
	let data = reactive({
		list: []
	})
	const buttonChouseId = ref('全部') //分类按钮点击状态的判断变量
	//分类按钮的点击事件
	const Event_clickChouseButton = (item) => {
		buttonChouseId.value = item
	}
	//门店列表点跳转二级页面 url携带门店信息
	const routerTo = (item) => {
		console.log(item)
		uni.navigateTo({
			url: `/pagesStore/detail/detail?store_id=${item.store_id}`
		});
	}
	const getList = () => {
		proxy.$https('/merchant_list_api', {
			province: "北京市",
			city: "北京市",
			district: "东城区",
			latitude: "39.92690120000003",
			longitude: "116.41003950000004",
			// classification: ""
		}).then(res => {
			console.log(res, 'res')
			data.list = res
		})
	}
	onShow(() => {
		console.log('load')
		getList()
	})
</script>

<style lang="scss" scoped>
	.box {
		display: flex;
		align-items: center;

		.search {
			display: flex;
			align-items: center;
			height: 68rpx;
			width: 686rpx;
			border-radius: 17pt;
			background-color: #F6F6F6;
			justify-content: space-evenly;

			.search-button {
				display: flex;

				.search-button-img {
					height: 32rpx;
					width: 32rpx;
				}

				.text {
					width: 84rpx;
					height: 40rpx;
					font-weight: bold;
					font-size: 28rpx;
					color: #333333;
					line-height: 33rpx;
				}
			}

			.line {
				background-color: #D9D9D9;
				height: 36rpx;
				width: 1rpx;
			}

			.uni-input {
				display: flex;
				width: 400rpx;
			}

		}

		.chose-box {
			display: flex;
			margin-top: 10rpx;
			align-items: center;

			.chose-all {
				.chose-image {
					width: 36rpx;
					height: 36rpx;
					margin-bottom: 5rpx;
				}

				.text-all {
					font-weight: 400;
					font-size: 28rpx;
					color: #666666;
					line-height: 33rpx;
				}

				.textAllactive {
					font-weight: bold;
					font-size: 28rpx;
					color: #333333;
					line-height: 33rpx;
				}

				.chose-line {
					width: 96rpx;
					height: 8rpx;
					background: linear-gradient(90deg, rgba(16, 199, 110, 0.6) 0%, rgba(16, 199, 110, 0.1) 100%);
					box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(16, 199, 110, 0.1);
					border-radius: 30rpx 30rpx 30rpx 30rpx;
				}
			}

			.choses-button-box {
				// margin-bottom: 36rpx;
				display: flex;
				align-items: center;

				.choses-button {
					margin-left: 40rpx; // border: 2px solid red;

					.choses-button-image {
						width: 36rpx;
						height: 36rpx;
						// margin-bottom: 4rpx;
					}

					.choses-button-text {
						width: 112rpx;
						height: 40rpx;
						font-weight: 400;
						font-size: 28rpx;
						color: #666666;
						line-height: 33rpx;
					}

					.trueButtonText {
						width: 56rpx;
						height: 40rpx;
						font-weight: bold;
						font-size: 28rpx;
						color: #333333;
						line-height: 33rpx;
					}

					.chose-line {
						width: 96rpx;
						height: 8rpx;
						background: linear-gradient(90deg, rgba(16, 199, 110, 0.6) 0%, rgba(16, 199, 110, 0.1) 100%);
						box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(16, 199, 110, 0.1);
						border-radius: 30rpx 30rpx 30rpx 30rpx;
					}
				}
			}

		}

		.content {
			position: absolute;
			top: 140rpx;
			bottom: 0;

			// border: 2px solid red;
			.card {
				display: flex;
				justify-content: space-evenly;
				align-items: center;
				margin-left: 32rpx;
				margin-right: 32rpx;
				margin-top: 10rpx;
				height: 188rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(51, 51, 51, 0.1);
				border-radius: 20rpx 20rpx 20rpx 20rpx;

				.card-left {
					width: 140rpx;
					height: 140rpx;
					border-radius: 20rpx 20rpx 20rpx 20rpx;

					.left-image {
						width: 140rpx;
						height: 140rpx;
						// margin-left: 24rpx;
					}
				}

				.card-right {
					margin-top: 126rpx;

					.text {
						width: 70rpx;
						height: 34rpx;
						font-weight: bold;
						font-size: 24rpx;
						color: #EE5618;
						line-height: 28rpx;
					}
				}

				.card-mid {
					.card-mid-text {
						width: 300rpx;
						height: 40rpx;
						font-weight: bold;
						font-size: 28rpx;
						color: #333333;
						line-height: 33rpx;
					}

					.mid-bottom {
						display: flex;

						.image {
							width: 24rpx;
							height: 26.31rpx;
						}

						.text {
							width: 356rpx;
							height: 34rpx;
							font-weight: 400;
							font-size: 24rpx;
							color: #666666;
							line-height: 28rpx;
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
						}
					}

					.mid-mid {
						display: flex;
						margin-top: 10rpx;
						margin-bottom: 18rpx;

						.mid-mid-status {
							width: 120rpx;
							height: 38rpx;
							border-radius: 4rpx 4rpx 4rpx 4rpx;
							border: 1rpx solid #10C76E;
							display: flex;
							justify-content: center;
							align-items: center;
							margin-right: 36rpx;

							.text {
								// width: 88rpx;
								height: 26rpx;
								font-weight: 400;
								font-size: 22rpx;
								color: #10C76E;
								line-height: 26rpx;
							}
						}

					}

				}
			}

		}
	}
</style>